package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDTO;
import com.zzyl.dto.NursingProjectPlanDTO;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVO;
import com.zzyl.vo.NursingProjectPlanVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划")
public class NursingPlanController extends BaseController{

    @Autowired
    private NursingPlanService nursingPlanService;

    /**
     * 查询所有护理计划
     * @return
     */
    @GetMapping
    public ResponseResult getAll(){
        List<NursingPlanVO> nursingPlanVOS = nursingPlanService.getAll();
        return success(nursingPlanVOS);
    }

    /**
     * 根据id查询护理计划
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult<NursingPlanVO> getById(
            @ApiParam(value = "护理计划id",required = true) @PathVariable Long id){
        NursingPlanVO nursingPlanVO = nursingPlanService.getById(id);
        return success(nursingPlanVO);
    }


    /**
     * 新增护理计划
     * @param nursingPlanDTO
     * @return
     */
    @PostMapping
    @ApiOperation("新增护理计划")
    public ResponseResult add(
            @ApiParam(value = "新增护理计划",required = true) @RequestBody NursingPlanDTO nursingPlanDTO){
        nursingPlanService.insert(nursingPlanDTO);
        return success();
    }

    /**
     * 条件分页查询
     * @return
     */
    @GetMapping("/search")
    @ApiOperation("条件分页查询")
    public ResponseResult<PageResponse<NursingPlanVO>> search(
            @ApiParam(value = "护理计划名称") @RequestParam(value = "name",required = false) String name,
            @ApiParam(value = "护理计划状态") @RequestParam(value = "status",required = false) Integer status,
            @ApiParam(value = "页码（默认为1）",required = true) @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页大小（默认为10）",required = true) @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){
        PageResponse<NursingPlanVO> pageResponse = nursingPlanService.getByPage(name,status,pageNum,pageSize);
        return success(pageResponse);
    }

    // /**
    //  * 修改
    //  * @param nursingProjectPlanVO
    //  * @return
    //  */
    // @PutMapping
    // @ApiOperation("修改")
    // public ResponseResult update(@RequestBody NursingProjectPlanVO nursingProjectPlanVO){
    //     nursingPlanService.update(nursingProjectPlanVO);
    //     return success();
    // }
    //
    // /**
    //  * 根据id删除护理计划
    //  * @param id
    //  * @return
    //  */
    // @DeleteMapping("/{id}")
    // @ApiOperation("根据id删除护理计划")
    // public ResponseResult delete(@PathVariable Integer id){
    //     nursingPlanService.delete(id);
    //     return success();
    // }
    //
    // /**
    //  * 启用修改
    //  * @param id
    //  * @param status
    //  * @return
    //  */
    // @PutMapping("/{id}/status/{status}")
    // @ApiOperation("启用修改")
    // public ResponseResult updateStatus(@PathVariable Integer id,@PathVariable Integer status){
    //     nursingPlanService.updateStatus(id,status);
    //     return success();
    // }
}
